package com.example.demo;

import com.example.demo.dao.UserDao;
import com.example.demo.entity.User;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.BeanDefinitionDsl;

@SpringBootApplication
@EnableCaching // 开启缓存注解功能
public class DemoApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = new SpringApplicationBuilder().sources(DemoApplication.class).run(args);
        UserDao userDao = context.getBean("userDao", UserDao.class);
        userDao.save(new User().setUsername("user").setPassword("user"));
        userDao.save(new User().setUsername("jack").setPassword("1234"));
        userDao.save(new User().setUsername("admin").setPassword("admin"));
    }
}
